package com.example.rikao1023.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

abstract class BaseActivity<VDB:ViewDataBinding,VM:ViewModel>(val layout:Int,val vm:VM):AppCompatActivity() {

    lateinit var binding:VDB
    lateinit var viewmodel:VM
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding=DataBindingUtil.setContentView(this,layout)
        viewmodel=ViewModelProvider(this).get(vm::class.java)
        initview()
        initdata()
    }

    abstract fun initdata()
    override fun onDestroy() {
        super.onDestroy()
        binding.unbind()
    }

    abstract fun initview()

}